package com.jlastu.dlxy_androidapp.view.main;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TableRow;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.jlastu.dlxy_androidapp.R;

public class AddActivity extends AppCompatActivity {

    private TableRow mGoodsRow;
    private TableRow mSchoolRow;

    private ImageView mClose;
    public class MainActivity extends AppCompatActivity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }

        @Override
        public void onConfigurationChanged(android.content.res.Configuration newConfig) {
            super.onConfigurationChanged(newConfig);

            // 检查屏幕方向是否为横屏
            if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
                Log.d("Orientation", "Landscape detected");

                // 创建并启动新的Activity
                Intent intent = new Intent(this, LandscapeActivity.class);
                startActivity(intent);

                // 可选：关闭当前Activity
                finish();
            }
        }
    }
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add);
        mGoodsRow = findViewById(R.id.add_goods);
        mSchoolRow = findViewById(R.id.add_school);
        mClose = findViewById(R.id.add_close);

        mGoodsRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(AddActivity.this, AddGoodsActivity.class);
                startActivity(intent);
                finish();
            }
        });
        mSchoolRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(AddActivity.this, AddSchoolActivity.class);
                startActivity(intent);
                finish();
            }
        });

        mClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    }
}

